package model

import (
	"github.com/google/uuid"
	"gorm.io/gorm"
)

type ProductType struct {
	Id              string `json:"id" gorm:"primaryKey;type:varchar(36);column:id;"`
	ProductTypeName string `json:"product_type_name" gorm:"type:varchar(255);column:product_type_name;uniqueIndex;not null;"`
	ProductTypeCode string `json:"product_type_code" gorm:"type:varchar(255);column:product_type_code;"`
	ProductTypeDesc string `json:"product_type_desc" gorm:"type:text;column:product_type_desc;"`
	SortCode        int64  `json:"sort_code" gorm:"type:bigint;column:sort_code;uniqueIndex;not null;"`
	CreatedAt       int64  `json:"created_at" gorm:"type:bigint;column:created_at;not null;"`
}

func (ProductType) TableName() string {
	return "product_type"
}

func (u *ProductType) BeforeCreate(tx *gorm.DB) (err error) {
	u.Id = uuid.NewString()
	return
}
